// ******************************************************************
// * Copyright(c)  Steven Lu
// * Description   : Entity_PROD_WIP_MTRL_HIS
// * CreateDate    : 2014-02-18 18:04:07
// * Creater       : CodeSmith
// * LastChangeDate: 2014-02-18 18:04:07
// * LastChanger   : 2014-02-18 18:04:07
// * Version Info  : 1.0 For ESOL
// ******************************************************************

using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Suzsoft.Smart.Data;
using ESOL.Common.Entity;

namespace ESOL.Business.Prod
{
/// <summary>
    /// ProdWipMtrlHis
    /// </summary>
    public partial class ProdWipMtrlHisBs
    {
        #region GetByID
        /// <summary>
        /// Get Entity
        /// </summary>
        /// <param name="objProdWipMtrlHisEntity">Entity</param>
        /// <returns>Entity</returns>
        public static ProdWipMtrlHisEntity GetProdWipMtrlHis(ProdWipMtrlHisEntity objProdWipMtrlHisEntity)
        {
            return DataAccess.SelectSingle<ProdWipMtrlHisEntity>(objProdWipMtrlHisEntity);
        }
        #endregion


        #region Insert
        /// <summary>
        /// Insert Data
        /// </summary>
        /// <param name="objProdWipMtrlHisEntity">Entity</param>
        /// <returns>true Insert Succeed; false Insert Fail</returns>
        public static bool InsertProdWipMtrlHis(ProdWipMtrlHisEntity objProdWipMtrlHisEntity)
        {
            return DataAccess.Insert(objProdWipMtrlHisEntity);
        }

        public static bool InsertProdWipMtrlHis(List<ProdWipMtrlHisEntity> objProdWipMtrlHisEntityList)
        {
            return DataAccess.Insert(objProdWipMtrlHisEntityList);
        }
        #endregion


        #region Update
        /// <summary>
        /// Update Data
        /// </summary>
        /// <param name="objProdWipMtrlHisEntity">Entity</param>
        /// <returns>true Update Succeed; false Update Fail</returns>
        public static bool UpdateProdWipMtrlHis(ProdWipMtrlHisEntity objProdWipMtrlHisEntity)
        {
            return DataAccess.Update(objProdWipMtrlHisEntity);
        }

        public static bool UpdateProdWipMtrlHis(List<ProdWipMtrlHisEntity> objProdWipMtrlHisEntityList)
        {
            return DataAccess.Update<ProdWipMtrlHisEntity>(objProdWipMtrlHisEntityList);
        }
        #endregion


        #region Delete
        /// <summary>
        /// Delete Data
        /// </summary>
        /// <param name="objProdWipMtrlHisEntity">Entity</param>
        /// <returns>true Delete Succeed; false Delete Fail</returns>
        public static bool DeleteProdWipMtrlHis(ProdWipMtrlHisEntity objProdWipMtrlHisEntity)
        {
            return DataAccess.Delete(objProdWipMtrlHisEntity);
        }

        public static bool DeleteProdWipMtrlHis(List<ProdWipMtrlHisEntity> objProdWipMtrlHisEntityList)
        {
            return DataAccess.Delete<ProdWipMtrlHisEntity>(objProdWipMtrlHisEntityList);
        }
        #endregion


        #region GetAll
        /// <summary>
        /// Get All Data
        /// </summary>
        /// <returns>Back All Data<returns>
        public static DataSet GetProdWipMtrlHisAll()
        {
            return DataAccess.SelectAllDataSet<ProdWipMtrlHisEntity>();
        }
        /// <summary>
        /// Get All Data List
        /// </summary>
        /// <returns>Back All Data List<returns>
        public static List<ProdWipMtrlHisEntity> GetProdWipMtrlHisAllList()
        {
            return DataAccess.SelectAll<ProdWipMtrlHisEntity>();
        }
        #endregion


        public static  DataSet GetProdWipMtrlHisDsByCondition(ProdWipMtrlHisEntity condition)
        {
            if (condition == null)
                return DataAccess.SelectAllDataSet<ProdWipMtrlHisEntity>();
            else
            {
                string strCondition = "";
                if (!string.IsNullOrEmpty(condition.WoId))
                    strCondition = " and Wo_ID like'%" + condition.WoId + "%'";
                //--where Event_Type='Mtrl_Asm' 
                string sql = @"select Wo_Id as Wo_No, Mtrl_Code,Mtrl_Name,SUM(MTRL_QTY) AS Mtrl_Qty,Unit from dbo.PROD_WIP_MTRL_HIS 
where 1=1 {0}
GROUP BY Wo_Id , Mtrl_Code,Mtrl_Name,Unit ";
                sql = string.Format(sql, strCondition);
                DataSet ds = DataAccess.SelectDataSet(sql);
                return ds;
            }
        }
	}
	
	
}	

